// 统计函数
export default function statistics(data, categoryField, valueField) {
    let countMap = {};
    let sumMap = {};

    data.forEach(item => {
        let category = item[categoryField];
        if (!countMap[category]) {
            countMap[category] = 0;
            sumMap[category] = 0;
        }
        countMap[category]++;
        sumMap[category] += item[valueField];
    });

    let result = {};
    for (let category in countMap) {
        result[category] = {
            "count": countMap[category],
            "sum": sumMap[category]
        };
    }

    return result;
}
